package com.user.profile.controller;

import com.alibaba.fastjson.JSON;
import com.user.profile.dao.LabelMapper;
import com.user.profile.request.SaveLabelRequest;
import com.user.profile.service.label.BuildCkManager;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author linlx
 * @Date 2021/9/13 15:26
 * @Description
 **/
@RestController
public class LabelController {

  @Resource
  private LabelMapper labelMapper;

  @Resource
  private BuildCkManager buildCkManager;

  @PostMapping("/saveLabel")
  public void saveLabel(@RequestBody SaveLabelRequest request) {
    labelMapper
        .save(request.getLabelName(), request.getParentOperate(),
            JSON.toJSONString(request));
  }

  @GetMapping("/buildCkQuery")
  public String buildCkQuery(@RequestParam Integer id) {
    return buildCkManager.buildCkQuery(id);
  }

}
